using System.Collections.Generic;

namespace Verse.AI;

public class JobDriver_Kill : JobDriver
{
	private const TargetIndex VictimInd = TargetIndex.A;

	public override bool TryMakePreToilReservations(bool errorOnFailed)
	{
		return pawn.Reserve(job.GetTarget(TargetIndex.A), job, 1, -1, null, errorOnFailed);
	}

	protected override IEnumerable<Toil> MakeNewToils()
	{
		this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Succeeded);
		yield return Toils_Combat.TrySetJobToUseAttackVerb(TargetIndex.A);
		Toil gotoCastPos = Toils_Combat.GotoCastPosition(TargetIndex.A, TargetIndex.None, closeIfDowned: false, 0.95f);
		yield return gotoCastPos;
		Toil jumpIfCannotHit = Toils_Jump.JumpIfTargetNotHittable(TargetIndex.A, gotoCastPos);
		yield return jumpIfCannotHit;
		yield return Toils_Combat.CastVerb(TargetIndex.A);
		yield return Toils_Jump.Jump(jumpIfCannotHit);
	}
}
